package com.springboot.service.impl;

import com.springboot.config.RabbitMQConfig;
import com.springboot.service.EmailService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by Administrator on 2017/7/3.
 */
@Service
public class EmailServiceImpl implements EmailService{
    private static Logger logger = LoggerFactory.getLogger(EmailServiceImpl.class);
    @Autowired
    private AmqpTemplate rabbitTemplate;
    /**
     * 发送邮件任务存入消息队列
     *
     * @param message
     * @throws Exception
     */
    @Override
    public void sendEmailMsg(String message) throws Exception {
        logger.info("邮件发送成功");
        rabbitTemplate.convertAndSend(RabbitMQConfig.EXCHANGE,RabbitMQConfig.ROUTEKEY,message);

    }

}
